<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/12/13 0013
 * Time: 上午 11:21
 */
header("Content-Type:application/json;charset=utf-8");
include "config.php";
if (isset($_REQUEST["gid"])){
    $str=file_get_contents("./data/goodsData.json");
    //1.把字符串转成对象
        $listArr=json_decode($str);
    //2.遍历对象
        foreach ($listArr as $item){

            if ($item->gid==$_REQUEST["gid"]){
                print_r(json_encode($item));
                return;
            }
        }
    //3.每一个对象里的id要和输入的id相等,就返回当前这条数据
}

